﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace TZL.Web.Controllers
{
    public class AdminLoginController : Controller
    {
        #region 用户登录
        // GET: AdminLogin
        public ActionResult Index()
        {
            if (Session["AdminUser"] != null)
            {
                return RedirectToAction("Index", "Admin");
            }
            return View();
        }

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns></returns>
        public JsonResult UserLogin(string userName, string password)
        {
            string name = ConfigurationManager.AppSettings["UserName"].ToString();
            string pwd = ConfigurationManager.AppSettings["PassWord"].ToString();
            if (userName == name && password == pwd)
            {
                Session["AdminUser"] = "admin";
                return Json(new { result = true });
            }
            else
            {
                return Json(new { result = false });
            }
        }
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns></returns>
        public ActionResult LoginOut()
        {
            Session["AdminUser"] = null;

            return RedirectToAction("Index", "Admin");
        }
        #endregion
    }
}